function getAllType() {
    $.ajax({
            url: address_head + "/api/GetAllType",
            async: true,
            type: "POST",
            // 成功后开启模态框
            success: function (data) {
                console.log(data);
                $("#tyle_list").html("")
                for (i in data) {// data.data指的是数组，数组里是对象，i为数组的索引
                    console.log(data[i]);
                    $html = $("<div onclick=\"getProjectListByType('" + data[i] + "')\" class=\"mycard\"><strong> " + data[i] + "</strong></div>");
                    $("#tyle_list").append($html);
                }
            },
            error:
                function () {
                    alert("请求失败");
                },
            dataType: "json"
        }
    )
    ;
}

function reloadMy(){
    location.reload();
}

/**
 * 点击类型根据类型查询项目列表
 * @param String
 */
function getProjectListByType(type) {
    if (type == null || type == undefined) {
        return;
    }
    $.ajax({
            url: address_head + "/api/GetProjectByType?type=" + type,
            async: true,
            type: "GET",
            // 成功后开启模态框
            success: function (data) {
                console.log(data);
                $html = $("<li> " + type + "</li>");
                $("#diretion").append($html);
                $("#detail_content").html("");
                $("#detail_content").append("<ul id=\"project_list\"></ul>")
                for (i in data) {// data.data指的是数组，数组里是对象，i为数组的索引
                    $html = $("<li onclick='javascript:window.location.href=\"project_detail.jsp?id=" + data[i].id + "\"'><div class=\"row clearfix\"><div class=\"col-md-12 column\"><h3>【" + data[i].number + "】 " + data[i].title + "</h3><p class=\"line-limit-length\">" + data[i].introduction + "</p>" +
                        "<div class=\"row clearfix\"><div class=\"col-md-8 column\"> " + getTypeHtml(data[i].typename) + "</div><div class=\"col-md-4 column\"><p>" +
                        "<small>" + data[i].releasetime + "</small></p></div></div></div></div><hr></li>");
                    $("#project_list").append($html);
                }
            },
            error:
                function () {
                    alert("请求失败");
                },
            dataType: "json"
        }
    )
    ;
}

function getAllProjectTitle() {
    $.ajax({
            url: address_head + "/api/GetAllProjectTitle",
            async: true,
            type: "POST",
            // 成功后开启模态框
            success: function (data) {
                console.log(data);
                for (i in data) {// data.data指的是数组，数组里是对象，i为数组的索引
                    console.log(data[i]);
                    $html = $("<div onclick='javascript:window.location.href=\"project_detail.jsp?id=" + data[i].id + "\"' class=\"mycard\"><strong> " + data[i].title + "</strong></div>");
                    $("#project_title_list").append($html);
                }
            },
            error:
                function () {
                    alert("请求失败");
                },
            dataType: "json"
        }
    )
    ;
}

/**
 *将类型的字符串根据逗号拆分显示
 * @param types
 */
function getTypeHtml(types) {
    var typename, types_html = "";
    if (types != null && types != undefined) {
        typename = types.split("，");
        for (var i in  typename) {
            types_html = types_html + "<span class=\"label label-default\">" + typename[i] + "</span>&nbsp";
        }
    } else {
        types_html = "";
    }
    //console.log("types_html:" + types_html);
    return types_html;
}